package id.co.shuba.spamobile.util;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.app.SherlockPreferenceActivity;

import id.co.shuba.spamobile.R;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;

public class StyleUtil {
	public static void applyStyle(SherlockActivity ctx) {
		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			Drawable bg = (Drawable) ctx.getResources().getDrawable(
					R.drawable.bg_action);
			ctx.getSupportActionBar().setBackgroundDrawable(bg);

			BitmapDrawable bgSplit = (BitmapDrawable) ctx.getResources()
					.getDrawable(R.drawable.bg_striped_split_img);
			bgSplit.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
			ctx.getSupportActionBar().setSplitBackgroundDrawable(bgSplit);
		}
	}
	
	public static void applyStyle(SherlockPreferenceActivity ctx) {
		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			Drawable bg = (Drawable) ctx.getResources().getDrawable(
					R.drawable.bg_action);
			ctx.getSupportActionBar().setBackgroundDrawable(bg);

			BitmapDrawable bgSplit = (BitmapDrawable) ctx.getResources()
					.getDrawable(R.drawable.bg_striped_split_img);
			bgSplit.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
			ctx.getSupportActionBar().setSplitBackgroundDrawable(bgSplit);
		}
	}
	
	public static void applyStyle(SherlockFragmentActivity ctx) {
		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			Drawable bg = (Drawable) ctx.getResources().getDrawable(
					R.drawable.bg_action);
			ctx.getSupportActionBar().setBackgroundDrawable(bg);

			BitmapDrawable bgSplit = (BitmapDrawable) ctx.getResources()
					.getDrawable(R.drawable.bg_striped_split_img);
			bgSplit.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
			ctx.getSupportActionBar().setSplitBackgroundDrawable(bgSplit);
		}
	}
}
